package com.ponhu.ea2.stockcenter.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * OMS订单商品信息
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "OMS订单商品信息")
public class OrderInventoryInfo implements Serializable {

    /**
     * 货品编码
     */
    @ApiModelProperty(value = "货品编码")
    @NotEmpty(message = "货品编码不为空")
    private String inventoryCode;

    /**
     * 货品数量
     */
    @ApiModelProperty(value = "货品数量")
    @Min(value = 1, message = "货品数量不能小于1")
    @NotNull(message = "货品数量不能为空")
    private Integer inventoryQuantity;

    public String getInventoryCode() {
        if (StringUtils.isNotEmpty(inventoryCode))
            return inventoryCode.trim();
        return inventoryCode;
    }
}
